﻿<%--<%@ Control Language="C#" Inherits="System.Web.Mvc.ViewUserControl<CRM.Models.TrainingsRequestsExt>" %>--%>
<%@ Control Language="C#" Inherits="System.Web.Mvc.ViewUserControl<CRM.Database.Model.TrainingsRequestsExt>" %>
<%@ Import Namespace="CRM.Resourses" %>
<%@ Import Namespace="System.Threading" %>
<%@ Import Namespace="CRM.Models" %>




<% Html.DevExpress().GridView(settings =>
                                    {
                                        settings.Name = "gdTrainingsParticipant";
                                        settings.KeyFieldName = "IdTrainingsParticipant";
                                        settings.CallbackRouteValues = new { Controller = "TC", Action = "TrainingsParticipantsPartial", key = Model.Key };
                                        settings.SettingsPager.PageSize = 20;

                                        settings.Columns.Add(column =>
                                        {
                                            column.Caption = Resourses.Name;
                                            column.FieldName = "ParticipantName";
                                            settings.Width = 100;
                                        });

                                        settings.Columns.Add(column =>
                                        {
                                            column.Caption = Resourses.TrainingsPosition; ;
                                            column.FieldName = "ParticipantPosition";
                                            settings.Width = 100;
                                        });

                                        if(Model.Request.IdTrainingsRequest > 0)
                                        {
                                            settings.Columns.Add(column =>
                                            {
                                                column.FieldName = "IdTrainingsParticipantsStatus";
                                                column.Caption = Resourses.TrainingParticipantsStatus;
                                                column.ColumnType = MVCxGridViewColumnType.ComboBox;
                                                column.ReadOnly = false;
                                                var comboBoxProperties = column.PropertiesEdit as ComboBoxProperties;
                                                if (comboBoxProperties != null)
                                                {
                                                    var statusesCol = new CRM.Database.Model.TrainingParticipantsStatusesCollection();
                                                    comboBoxProperties.DataSource = statusesCol.TrainingParticipantsStatusesActiveList;
                                                    //comboBoxProperties.DataSource = DB.GetLocalizedTrainingParticipantsStatusesNames(Thread.CurrentThread.CurrentCulture.ToString());
                                                    comboBoxProperties.TextField = "LocalizedName";
                                                    comboBoxProperties.ValueField = "IdTrainingParticipantsStatus";
                                                    comboBoxProperties.ValueType = typeof(int);
                                                }
                                            });
                                        }

                                        settings.CommandColumn.Visible = true;
                                        settings.CommandColumn.NewButton.Visible = true;
                                        settings.CommandColumn.DeleteButton.Visible = true;
                                        settings.CommandColumn.EditButton.Visible = true;
                                        settings.SettingsBehavior.ConfirmDelete = true;
                                        settings.SettingsEditing.Mode = GridViewEditingMode.EditFormAndDisplayRow;
                                        settings.Width = 500;
                                        settings.SettingsEditing.AddNewRowRouteValues = new { Controller = "TC", Action = "TrainingsParticipantsPartialAdd", key = Model.Key };
                                        settings.SettingsEditing.DeleteRowRouteValues = new { Controller = "TC", Action = "TrainingsParticipantsPartialDelete", key = Model.Key };
                                        settings.SettingsEditing.UpdateRowRouteValues = new { Controller = "TC", Action = "TrainingsParticipantsPartialUpdate", key = Model.Key };
                                    }).Bind(Model.ParticipantsList).GetHtml();
%>